package com.geek.gkfgw.util.excp;

/**
 * <h1>异常编码。</h1><br/>
 *
 * <h1><br/><a href="https://u.geekbang.org/subject/arch3/100614201">Java 业务架构实战营：https://u.geekbang.org/subject/arch3/100614201</a></h1><br/><h1><a href="https://gitee.com/ylimhhmily/BizArchPracticeCamp">Java 业务架构实战营代码地址：https://gitee.com/ylimhhmily/BizArchPracticeCamp</a></h1><br/><h1><a href="https://u.geekbang.org/subject/java4th/1001148?source=app_share">高级 Java 工程体系课 2023 版：https://u.geekbang.org/subject/java4th/1001148?source=app_share</a></h1><br/><h1><a href="https://time.geekbang.org/column/intro/100312101?tab=catalog">Dubbo 源码剖析与实战：https://time.geekbang.org/column/intro/100312101?tab=catalog</a></h1>
 *
 * @author hmilyylimh
 * ^_^
 * @version 0.0.1
 * ^_^
 * @date 2022-02-18
 */
public enum GkFgwCodeEnum {

    /** <h2>"000000", "成功"</h2> */
    SUCCESS("000000", "成功"),

    /** <h2>"801001", "参数异常"</h2> */
    ARGS_ERROR("801001", "参数异常"),
    /** <h2>"801002", "插入数据异常"</h2> */
    INSERT_DATA_ERROR("801002", "插入数据异常"),
    /** <h2>"801003", "令牌丢失"</h2> */
    LOSS_TOKEN("801003", "令牌丢失"),
    /** <h2>"801004", "获取序列号失败"</h2> */
    GET_SEQUENCE_FAILED("801004", "获取序列号失败"),
    /** <h2>"801005", "令牌无效"</h2> */
    INVALID_TOKEN("801005", "令牌无效"),

    /** <h2>"801998", "调用下游异常"</h2> */
    INVOKE_INTEGRATION_EXCEPTION("801998", "调用下游异常"),
    /** <h2>"801999", "系统异常"</h2> */
    SYSTEM_EXCEPTION("801999", "系统异常"),

    ;

    private final String code;
    private final String msg;

    GkFgwCodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * <h2>是否是失败的，true-失败。</h2>
     *
     * @param: respCode
     * @return: boolean
     */
    public static boolean isFail(String respCode) {
        return !SUCCESS.getCode().equals(respCode);
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
